package com.raidan.dclog.core;

/**
 * Primitive for time counting. Just for non copy-past
 * System.currentTimeMillis()
 * 
 * @author raidan
 * 
 */
public class Secundomer {

	private boolean started = false;
	private long time;

	/**
	 * Start
	 */
	public void start() {
		this.time = System.currentTimeMillis();
		started = true;
	}

	/**
	 * Stop
	 */
	public void stop() {
		if (started) {
			this.time = System.currentTimeMillis() - time;
			started = false;
		}
	}

	/**
	 * Return time between start and stop in msec
	 * 
	 * @return time between start and stop, or -1 if secundomer not stopped
	 */
	public int getTotalTime() {
		if (!started) {
			return (int) this.time;
		} else {
			return -1;
		}
	}
}
